package com.tech.cloudapp.po;

import com.tech.cloudapp.db.entity.QuestionUserAnswer;
import lombok.Data;
import org.apache.commons.lang3.ArrayUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
public class QuestionUserAnswerParamPO extends SuperPO {

    /**
     * 分类ID
     */
    @NotNull(message = "证书ID不能为空",groups = {CheckA.class,CheckB.class})
    private Integer classifyId;

    /**
     * 所属试卷ID
     */
    @NotNull(message = "题库ID不能为空",groups = {CheckA.class,CheckB.class})
    private Integer paperId;


    @NotEmpty(message = "用户ID不能为空",groups = {CheckA.class,CheckB.class,CheckC.class})
    private String userId;

    @NotNull(message =  "答案不能为空",groups = {CheckA.class})
    private List<QuestionUserAnswerPO> questionUserAnswers;


    @Data
    public static class QuestionUserAnswerPO
    {
        private int questionInfoId;
        private int classifyId;
        private int paperId;
        private List<String> userAnswer;
        private int isRight;
        private String answerTime;
        private String userId;


        public String getUserAnswer()
        {
            return ArrayUtils.toString(this.userAnswer);
        }
    }

    public interface CheckA{}
    public interface CheckB{}
    public interface CheckC{}
}
